﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZDSoft.QLMS.Web.Tools.CheckCode;
using ZDSoft.QLMS.Web.Helpers;

namespace ZDSoft.QLMS.Web.Controllers
{
    public class CommonController : Controller
    {
        /// <summary>
        /// 生成验证码图像对象
        /// </summary>
        /// <returns></returns>
        public ActionResult GetValidateCode()
        {
            ValidateCode vCode = new ValidateCode();
            string code = vCode.CreateValidateCode(4);
            Session["ValidateCode"] = code;
            byte[] bytes = vCode.CreateValidateGraphic(code);
            return File(bytes, @"image/jpeg");
        }

        /// <summary>
        /// 得到当前验证码
        /// </summary>
        /// <returns></returns>
        public ActionResult GetCurrentValidateCode()
        {
            return Content(Session["ValidateCode"].ToString());
        }
    }
}
